<!--
 * @Autor: dingxiaolin
 * @Date: 2020-11-28 14:49:18
 * @LastEditors: dingxiaolin
 * @LastEditTime: 2021-09-01 19:00:43
-->
<template>
    <view id="login">
        {{ userInfo.name }} {{ sex }}
        <van-button @click="login">登ss录</van-button>
        <view class="page__bd"> </view>
        <van-toast id="van-toast" />
        <van-dialog id="van-dialog" />
    </view>
</template>

<script>
import { mapState, mapGetters, mapMutations, mapActions } from "vuex";
import Toast from "@/wxcomponents/vant/toast/toast";
import Dialog from "@/wxcomponents/vant/dialog/dialog";
export default {
    components: {},
    // 使用对象展开运算符将此对象混入外部对象中
    //    computed: {...mapState(["userInfo"])}, 根state
    computed: {
        ...mapState({
            userInfo: (state) => state.user.userInfo,
            sex: (state) => state.global.sex,
        }),
        // ...mapState('user',{
        //   userInfo:  state => state.userInfo,
        // })
    },
    data() {
        return {
            list: [],
        };
    },

    created() {
        // uni.setNavigationBarTitle({
        //         title: "凉州区网络祭扫平台"
        // })
        // wx.cloud.callFunction({name:'getid'}).then(res=>{
        //     console.log('ttttt',res.result.openid);
        //     wx.setStorageSync('openid',res.result.openid)
        // })
        //实时定位
        // wx.startLocationUpdateBackground({
        //     success(res) {
        //         console.log("开启后台定位", res);
        //         const _locationChangeFn = function (res) {
        //             console.log("location change", res);
        //         };
        //         wx.onLocationChange(_locationChangeFn);
        //     },
        //     fail(res) {
        //         console.log("开启后台定位失败", res);
        //     },
        // });
        wx.getLocation({
            // type: "gcj02", //默认wgs84
            isHighAccuracy: true,
            success(res) {
                console.log("gcj02", res);
                const latitude = res.latitude;
                const longitude = res.longitude;
                const speed = res.speed;
                const accuracy = res.accuracy;
            },
        });
    },
    onShow() {},

    onUnload() {},

    methods: {
        login() {
            console.log("tttt");
            Toast("测试");
            // wx.redirectTo({ url: "/sub_pages/subtest/index" });
        },
        // 将 `this.login()` 映射为 `this.$store.dispatch('user/login')`
        //  ...mapActions('user',[
        //      'login',
        //     ]),
        // ...mapActions({
        //     login: "user/login",
        // }),
    },
};
</script>
<style lang="scss">
@import "../../style/variables.scss"; //只能每个页面都引入这些变量
page {
    background: $uni-bg-color-green;
}
</style>
<style scoped lang="scss">
#login {
    width: 100%;
    // height:100%;
    .logo {
        height: 400rpx;
        margin-bottom: 40rpx;
        .logo-img {
            width: 100%;
            height: 100%;
        }
    }
    .btnGroup {
        margin-bottom: 40rpx;
        .success {
            margin: 20rpx 40rpx;
            background: #46b62c;
            color: #fff;
            height: 80rpx;
            line-height: 80rpx;
        }
    }
}
</style>
